-
Notifications
You must be signed in to change notification settings - Fork 854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build against NPY2 #3894
build against NPY2 #3894
Conversation
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Unluckily, there are still several errors. Some are related to the upstream chgnet and scipy and cannot be fixed here. |
Signed-off-by: Jinzhe Zeng <[email protected]>
e3fbc67
to
41e6d99
Compare
@njzjz sorry for the lack of reply here! looks like this is almost finished. thanks for the effort! feel free to skip the failing chgnet tests for now. re |
I really appreciate the pioneering work @njzjz! Meanwhile in case anyone missed this,
|
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
For cross reference, I've submitted the SciPy issue to scipy/scipy#21052 |
I do not know how to fix the rest of the errors and need help. |
@njzjz feel free to skip the two failing @pytest.mark.skipif(sys.platform == "win32" and np.__version__ > "2.0.0", reason="Fails on Windows with numpy > 2.0.0, awaiting https://github.com/scipy/scipy/issues/21052 resolution")
def test_delta_func():
x = np.array([0, 1, 2, 3, 4, 5]) not sure about |
Just did some investigation on the failure of I believe this failure has something to do with the float point precision (though I don't know exactly how), with the following script on Windows Python 3.12: import numpy as np
from pymatgen.io.vasp import Poscar, Wavecar
TEST_DIR = "tests/files/io/vasp"
poscar = Poscar.from_file(f"{TEST_DIR}/inputs/POSCAR")
w = Wavecar(f"{TEST_DIR}/outputs/WAVECAR.H2.ncl")
w.coeffs.append([np.ones((2, 100))])
c = w.get_parchg(poscar, -1, 0, phase=False, spinor=None)
print(np.min(c.data["total"])) # 0.0 in NumPy 1.x, 8.738907122657083e-33 in NumPy 2.x
assert not np.all(c.data["total"] > 0.0) # AssertionError Note the min value in From the "NumPy 2.0 migration guide", there seems to be two changes related to this:
However, with these changes, I would expect the precision on Windows to be consistent with Linux on NumPy 2.x. Perhaps someone more familiar with the internal workings of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot @njzjz for this work and esp. for reporting multiple upstream issues! 🥇 and thanks @DanielYang59 for supporting! good team effort to get the many failing tests here sorted out.
The failing tests for |
@@ -50,7 +50,8 @@ class LinearAssignment: | |||
""" | |||
|
|||
def __init__(self, costs, epsilon=1e-13): | |||
self.orig_c = np.array(costs, dtype=np.float_, copy=False, order="C") | |||
# https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janosh This doesn't look like something we should keep inside the code (it's pretty easy to find)? What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm generally in favor of linking relevant docs. even if easy to find, people might not think to look for them. but no strong opinion in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one looks more like a "disposable" migration guide which we would only do once :)
probably something to report to https://github.com/Unidata/netcdf4-python, even if just to say the error message is self-contradictory...
|
Agreed, just for my own record, it failed in another PR randomly https://github.com/materialsproject/pymatgen/actions/runs/10268736299/job/28412461926?pr=3892 |
This part of the code is generated by delvewheel here. I think I can report there. According to the Windows documentation, this error message means no error. So it may be incorrect to throw an error (while it is also strange that
See also https://stackoverflow.com/questions/7524142/what-does-windows-error-0-error-success-mean |
Submitted to adang1345/delvewheel#51 |
@njzjz can you pin pyproject to the fixed |
temp install delvewheel>=1.7.4 in CI
Signed-off-by: Jinzhe Zeng <[email protected]>
Head branch was pushed to by a user without write access
This may not work, as delvewheel is a build-time dependency, not a runtime dependency. |
ah, didn't realize that. so the place to pin that would be here Lines 1 to 4 in 1dfc9e4
but looks like we're in the green anyway so would be good to remove the temp install command in |
thanks again @njzjz! 👍 |
Just recorded another failure in https://github.com/materialsproject/pymatgen/actions/runs/10319015504/job/28566565139:
|
Summary
Major changes:
np.int_t
(missing in NPY2) withnp.int64_t
andnp.float_
withnp.float64
.long
withnp.int64_t
, as "The default integer type on Windows is now int64 rather thanint32, matching the behavior on other platforms" per the change log of NPY2.
Todos
If this is work in progress, what else needs to be done?
Checklist
ruff
.mypy
.duecredit
@due.dcite
decorators to reference relevant papers by DOI (example)Tip: Install
pre-commit
hooks to auto-check types and linting before every commit: